package com.crl.game.simulation.common
{
	import com.crl.game.simulation.server.decoder.IServerDecoder;
	import com.crl.game.simulation.server.decoder.IServerRouter;
	import com.crl.game.simulation.server.Actor;
	import com.crl.net.transfer.Command;
	
	import flash.utils.Dictionary;
	
	/**
	 * 路由器 
	 * @author crl
	 * 
	 */	
	public class Router implements IServerRouter
	{
		private var decodes:Dictionary;
		protected var simulation:BaseSimulation;
		
		private var buffer:Vector.<Command>;
		public function Router(simulation:BaseSimulation)
		{
			decodes=new Dictionary();
			
			buffer=new Vector.<Command>;
			
			this.simulation=simulation;
		}
		
		public function route(command:Command,actor:Actor):void{
			var decoder:IServerDecoder=decodes[command.code];
			if(decoder)decoder.decode(command,actor);
		}
		
		public function send(command:Command,actor:Actor):void{
			actor.sendCommand(command);
		}
	}
}